<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			function f1(){
				console.log($("input:checked"));
				var str = "";
				for (var i = 0;i < $("input:checked").length;i++) {
					str +=$("input:checked:eq("+i+")").val() + ",";
				}
				console.log(str);
				str = str.substr(0,str.length - 1);
				console.log(str);
			}
			function f2(){
				$(".hby").val([22.33]).attr("checked",true);
			}
		</script>
	</head>
	<body>
		<h1>复选框操作</h1>

        爱好：
        <input type="checkbox" class="hby" name="hobby" value="11" />篮球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="22" />足球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="33" />排球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="44" />乒乓球&nbsp;
        
        <br /><br />
        <input type="button" value="获取" onclick="f1()" />
        <input type="button" value="设置" onclick="f2()" />
	</body>
</html>
